import { managementService } from '~/config/server';
import { NetService } from '~/utils/net.service';
import { Inject, Debounce } from '~/core/decorator';

export class ResourceService {
  @Inject(NetService)
  private netService: NetService;

  /**
   * 获取全部资源信息
   */
  @Debounce()
  public getResourceAll() {
    return this.netService.send({
      server: managementService.resourceController.getResourceAll
    });
  }
  @Debounce()
  public getResourceAllPage(resource,page) {
    return this.netService.send({
      server: managementService.resourceController.getResourceAllPage,
      data:resource,
      page
    });
  }
  @Debounce()
  public createResource(data) {
    return this.netService.send({
      server: managementService.resourceController.createResource,
      data,
      loading: true,
    });
  }
  @Debounce()
  public deleteResourceById(id) {
    return this.netService.send({
      server: managementService.resourceController.deleteResourceById,
      data: {
        id
      }
    });
  }

}
